/**********************************************************
 * SearchCriteria.java
 * Created by ankur
 * Last modified Date: Aug 5, 2008 11:41:03 AM by ankur
 * Version : 0.1
 * Copyright (c) 2008 - 2008 cyberThink Infotech Pvt. Ltd., All rights reserved.
 **********************************************************/

package com.printeverywhere.util;

import org.apache.log4j.Logger;
import java.util.HashMap;
import java.util.Set;

/**
 * The Class SearchCriteria.
 */

public class SearchCriteria {
	
	/** Logger for this class. */
	private static final Logger logger = Logger.getLogger(SearchCriteria.class);

	/** The attributes. */
	private HashMap<String, Object> attributes = new HashMap<String, Object>();

	/** The order by. */
	private String orderBy = null;

	/** The asc. */
	private boolean asc;

	/**
	 * Gets the attribute.
	 * 
	 * @param key the key
	 * 
	 * @return the attribute
	 */
	public Object getAttribute(String key) {
		if (logger.isDebugEnabled()) {
			logger.debug("getAttribute(String) - start"); //$NON-NLS-1$
		}

		Object returnObject = attributes.get(key);
		if (logger.isDebugEnabled()) {
			logger.debug("getAttribute(String) - end"); //$NON-NLS-1$
		}
		return returnObject;
	}

	/**
	 * Gets the attribute names.
	 * 
	 * @return the attribute names
	 */
	public Set<String> getAttributeNames() {
		if (logger.isDebugEnabled()) {
			logger.debug("getAttributeNames() - start"); //$NON-NLS-1$
		}

		Set<String> returnSet = attributes.keySet();
		if (logger.isDebugEnabled()) {
			logger.debug("getAttributeNames() - end"); //$NON-NLS-1$
		}
		return returnSet;
	}

	/**
	 * Gets the order by.
	 * 
	 * @return the order by
	 */
	public String getOrderBy() {
		return orderBy;
	}

	/**
	 * Checks if is asc.
	 * 
	 * @return true, if is asc
	 */
	public boolean isAsc() {
		return asc;
	}

	/**
	 * Removes the all attribute.
	 */
	public void removeAllAttribute() {
		if (logger.isDebugEnabled()) {
			logger.debug("removeAllAttribute() - start"); //$NON-NLS-1$
		}

		attributes.clear();

		if (logger.isDebugEnabled()) {
			logger.debug("removeAllAttribute() - end"); //$NON-NLS-1$
		}
	}

	/**
	 * Removes the attribute.
	 * 
	 * @param key the key
	 * 
	 * @return the object
	 */
	public Object removeAttribute(String key) {
		if (logger.isDebugEnabled()) {
			logger.debug("removeAttribute(String) - start"); //$NON-NLS-1$
		}

		Object returnObject = attributes.remove(key);
		if (logger.isDebugEnabled()) {
			logger.debug("removeAttribute(String) - end"); //$NON-NLS-1$
		}
		return returnObject;
	}

	/**
	 * Sets the asc.
	 * 
	 * @param asc the new asc
	 */
	public void setAsc(boolean asc) {
		this.asc = asc;
	}

	/**
	 * Sets the attribute.
	 * 
	 * @param key the key
	 * @param value the value
	 */
	public void setAttribute(String key, Object value) {
		if (logger.isDebugEnabled()) {
			logger.debug("setAttribute(String, Object) - start"); //$NON-NLS-1$
		}

		attributes.put(key, value);

		if (logger.isDebugEnabled()) {
			logger.debug("setAttribute(String, Object) - end"); //$NON-NLS-1$
		}
	}

	/**
	 * Sets the order by.
	 * 
	 * @param orderBy the new order by
	 */
	public void setOrderBy(String orderBy) {
		this.orderBy = orderBy;
	}
}